package com.ruoyi.production.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Date;

/**
 * 报工记录对象 work_report
 *
 * @author ruoyi
 * @date 2022-09-05
 */
public class WorkReport extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * $column.columnComment
     */
    @Excel(name = "序号")
    private Long id;

    /**
     * 工单编号
     */
    @Excel(name = "工单编号")
    private String workOrderNo;

    /**
     * 报工编号
     */
    @Excel(name = "报工编号")
    private String workReportNo;

    /**
     * 关联项目
     */
    @Excel(name = "关联项目")
    private String projectNo;

    /**
     * 项目名称
     */
    @Excel(name = "项目名称")
    private String projectName;

    /**
     * 工序编号
     */
    @Excel(name = "工序编号")
    private String procedureNo;

    /**
     * 工序名称
     */
    @Excel(name = "工序名称")
    private String procedureName;

    /**
     * 加工顺序
     */
    @Excel(name = "加工顺序")
    private String sort;

    /**
     * 报工时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "报工时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date reportingTime;

    /**
     * 报工数量
     */
    @Excel(name = "报工数量")
    private Long reportingCount;

    /**
     * 报工重量
     */
    @Excel(name = "报工重量")
    private Long reportWeight;

    /**
     * 产出重量
     */
    @Excel(name = "产出重量")
    private Long outputWeight;

    /**
     * 合格数量
     */
    @Excel(name = "合格数量")
    private Long qualifiedQuantity;
    /**
     * 不合格数量
     */
    private Long unQualifiedQuantity;

    @Excel(name = "合格率")
    private String passRate;

    /**
     * 班组名称
     */
    @Excel(name = "班组名称")
    private String teamName;

    /**
     * 班组编号
     */
    private String teamNo;

    /**
     * 质检人
     */
    @Excel(name = "质检人")
    private String qualityPerson;


    /**
     * 质检时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "质检时间", width = 30, dateFormat = "yyyy-MM-dd")
    private Date qualityTime;

    /**
     * 质检状态
     */
    @Excel(name = "质检状态",readConverterExp = "0=未质检,1=已质检")
    private String qualityStatus;

    //报工类型
    private String reportType;

    public String getReportType() {
        return reportType;
    }

    public void setReportType(String reportType) {
        this.reportType = reportType;
    }

    public Long getUnQualifiedQuantity() {
        return unQualifiedQuantity;
    }

    public void setUnQualifiedQuantity(Long unQualifiedQuantity) {
        this.unQualifiedQuantity = unQualifiedQuantity;
    }

    public String getPassRate() {
        String result = "";
        if (qualifiedQuantity == null){
            return String.valueOf("0%");
        }
        try{
            double l = (double) getQualifiedQuantity()/ (double) (getUnQualifiedQuantity() + getQualifiedQuantity());
            return String.valueOf(l*100) + "%";
        }catch (Exception e){
            e.printStackTrace();
        }
        return "0%";
    }

    public void setPassRate(String passRate) {
        this.passRate = passRate;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setWorkReportNo(String workReportNo) {
        this.workReportNo = workReportNo;
    }

    public String getWorkReportNo() {
        return workReportNo;
    }

    public void setWorkOrderNo(String workOrderNo) {
        this.workOrderNo = workOrderNo;
    }

    public String getWorkOrderNo() {
        return workOrderNo;
    }

    public void setProjectNo(String projectNo) {
        this.projectNo = projectNo;
    }

    public String getProjectNo() {
        return projectNo;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProcedureNo(String procedureNo) {
        this.procedureNo = procedureNo;
    }

    public String getProcedureNo() {
        return procedureNo;
    }

    public void setProcedureName(String procedureName) {
        this.procedureName = procedureName;
    }

    public String getProcedureName() {
        return procedureName;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getSort() {
        return sort;
    }

    public void setReportingTime(Date reportingTime) {
        this.reportingTime = reportingTime;
    }

    public Date getReportingTime() {
        return reportingTime;
    }

    public void setReportingCount(Long reportingCount) {
        this.reportingCount = reportingCount;
    }

    public Long getReportingCount() {
        return reportingCount;
    }

    public void setReportWeight(Long reportWeight) {
        this.reportWeight = reportWeight;
    }

    public Long getReportWeight() {
        return reportWeight;
    }

    public void setQualifiedQuantity(Long qualifiedQuantity) {
        this.qualifiedQuantity = qualifiedQuantity;
    }

    public Long getQualifiedQuantity() {
        return qualifiedQuantity;
    }

    public void setOutputWeight(Long outputWeight) {
        this.outputWeight = outputWeight;
    }

    public Long getOutputWeight() {
        return outputWeight;
    }

    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }

    public String getTeamName() {
        return teamName;
    }

    public void setTeamNo(String teamNo) {
        this.teamNo = teamNo;
    }

    public String getTeamNo() {
        return teamNo;
    }

    public void setQualityPerson(String qualityPerson) {
        this.qualityPerson = qualityPerson;
    }

    public String getQualityPerson() {
        return qualityPerson;
    }

    public void setQualityTime(Date qualityTime) {
        this.qualityTime = qualityTime;
    }

    public Date getQualityTime() {
        return qualityTime;
    }

    public void setQualityStatus(String qualityStatus) {
        this.qualityStatus = qualityStatus;
    }

    public String getQualityStatus() {
        return qualityStatus;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("workReportNo", getWorkReportNo())
                .append("workOrderNo", getWorkOrderNo())
                .append("projectNo", getProjectNo())
                .append("projectName", getProjectName())
                .append("procedureNo", getProcedureNo())
                .append("procedureName", getProcedureName())
                .append("sort", getSort())
                .append("reportingTime", getReportingTime())
                .append("reportingCount", getReportingCount())
                .append("reportWeight", getReportWeight())
                .append("qualifiedQuantity", getQualifiedQuantity())
                .append("outputWeight", getOutputWeight())
                .append("teamName", getTeamName())
                .append("teamNo", getTeamNo())
                .append("qualityPerson", getQualityPerson())
                .append("qualityTime", getQualityTime())
                .append("qualityStatus", getQualityStatus())
                .toString();
    }
}
